﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MapManager : MonoBehaviour {

    //房间的宽高（个数，几个单元格）
    //public int roomWidth = 18;
    //public int roomHeigth = 10;
    //单元格宽高
    //public float cellWidth = 1;
    //public float cellHeigth = 1;
    //房间列表
    public List<Room> roomList = new List<Room>();
    //房间中心点
    public Vector3 roomCenter = new Vector3(0, 0, 0);
    //预制物
    public GameObject wallPrefab;
    public GameObject floorPrefab;

	// Use this for initialization
	void Start () {
        //CreateWallAndFloor(new Vector2(0, 0) ,18, 10);
        //Room room = new Room(new Vector2(0, 0), 18, 10, wallPrefab, floorPrefab);

        //创建房间
        CreateMapRoom(3, 4, 5, 5, 18, 15, wallPrefab, floorPrefab);
        //随机选择一个房间

        //打通通道

        //房间生成物品

    }
	
	// Update is called once per frame
	void Update () {
		
	}

    /// <summary>
    /// 创建房间
    /// </summary>
    /// <param name="row"></param>
    /// <param name="col"></param>
    /// <param name="gapRow"></param>
    /// <param name="gapCol"></param>
    /// <param name="roomWidth"></param>
    /// <param name="roomHeigth"></param>
    /// <param name="wall"></param>
    /// <param name="floor"></param>
    public void CreateMapRoom(int row, int col,int gapRow, int gapCol, int roomWidth, int roomHeigth, GameObject wall, GameObject floor)
    {
        Vector2 createPos = Vector2.zero;
        for (int i = 0; i < row * col; i++)
        {
            Room room = new Room(createPos, roomWidth, roomHeigth, wall, floor);
            roomList.Add(room);
            createPos.x += roomWidth + gapCol;
            if ((i + 1)  % col == 0)
            {
                createPos.y -= (roomHeigth + gapRow);
                createPos.x = 0;
            }
        }
    }

    //创建障碍物
    public void CreateObs()
    {

    }
}
